package com.project.server.service.operate.impl;

import com.project.common.core.domain.BaseServer;
import com.project.server.domain.operate.TOperateEmergency;
import com.project.server.mapper.operate.TOperateEmergencyMapper;
import com.project.server.service.operate.ITOperateEmergencyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import static com.project.server.utils.DelTagUtil.getTextFromHtml;

/**
 * 运营管理应急处理Service业务层处理
 *
 * @author project
 * @date 2021-06-29
 */
@Service
public class TOperateEmergencyServiceImpl extends BaseServer implements ITOperateEmergencyService {

    private static final Logger log = LoggerFactory.getLogger(TOperateEmergencyServiceImpl.class);

    @Resource
    private TOperateEmergencyMapper tOperateEmergencyMapper;

    /**
     * 查询运营管理应急处理
     *
     * @param emergencyId 运营管理应急处理ID
     * @return 运营管理应急处理
     */
    @Override
    public TOperateEmergency selectTOperateEmergencyById(Long emergencyId) {
        return tOperateEmergencyMapper.selectTOperateEmergencyById(emergencyId);
    }

    /**
     * 查询运营管理应急处理列表
     *
     * @param tOperateEmergency 运营管理应急处理
     * @return 运营管理应急处理
     */
    @Override
    public List<TOperateEmergency> selectTOperateEmergencyList(TOperateEmergency tOperateEmergency) {
        return tOperateEmergencyMapper.selectTOperateEmergencyList(tOperateEmergency);
    }

    /**
     * 处理导出内容中的html标签
     */
    @Override
    public  List<TOperateEmergency> selectTOperateEmergencyDelTags(TOperateEmergency tOperateEmergency){
        List<TOperateEmergency> operateEmergencies = tOperateEmergencyMapper.selectTOperateEmergencyList(tOperateEmergency);
        for(int i = 0;i<operateEmergencies.size();i++){
            TOperateEmergency tOperateEmergency1 = operateEmergencies.get(i);
            tOperateEmergency1.setEmergencyContent(getTextFromHtml(tOperateEmergency1.getEmergencyContent()));
        }
        return operateEmergencies;
    }

    /**
     * 新增运营管理应急处理
     *
     * @param tOperateEmergency 运营管理应急处理
     * @return 结果
     */
    @Override
    public int insertTOperateEmergency(TOperateEmergency tOperateEmergency) {
        super.insert(tOperateEmergency);
        return tOperateEmergencyMapper.insertTOperateEmergency(tOperateEmergency);
    }

    /**
     * 修改运营管理应急处理
     *
     * @param tOperateEmergency 运营管理应急处理
     * @return 结果
     */
    @Override
    public int updateTOperateEmergency(TOperateEmergency tOperateEmergency) {
        super.update(tOperateEmergency);
        return tOperateEmergencyMapper.updateTOperateEmergency(tOperateEmergency);
    }

    /**
     * 批量删除运营管理应急处理
     *
     * @param emergencyIds 需要删除的运营管理应急处理ID
     * @return 结果
     */
    @Override
    public int deleteTOperateEmergencyByIds(Long[] emergencyIds) {
        return tOperateEmergencyMapper.deleteTOperateEmergencyByIds(emergencyIds);
    }

    /**
     * 删除运营管理应急处理信息
     *
     * @param emergencyId 运营管理应急处理ID
     * @return 结果
     */
    @Override
    public int deleteTOperateEmergencyById(Long emergencyId) {
        return tOperateEmergencyMapper.deleteTOperateEmergencyById(emergencyId);
    }
}
